public class Solution {
    public int lengthOfLastWord(String s) {
        String s1 = s.trim();
        return s1.substring(s1.lastIndexOf(' ') + 1).length();
    }
}